/*
 * @Descripttion:
 * @Author: congz
 * @Date: 2020-07-20 11:08:33
 * @LastEditors: congz
 * @LastEditTime: 2020-08-05 15:32:59
 */
import axios from 'axios'
import request from '@/api/utils/request'
// 创建购物车
import qs from 'qs'

export function showAddress(id) {
  let target = '/getAddress?user_id=' + id
  return request.get(target)
}

export function getDetailAddress(id,aid) {
  let target = '/getUaddress?user_id=' + id +'&address_id='+ aid
  return request.get(target)
}
// 读取购物车
// const showAddresses = user_id =>
//   axios.get(`/api/v1/addresses/${user_id}`).then(res => res.data)
export function getAddress(user_id) {
  let target = '/getAddress?user_id=' + user_id
  return request.get(target)
}

// 更新购物车
// const updateAddress = form =>
//   axios.put('/api/v1/addresses', form).then(res => res.data)
export function updateAddress(form) {
  let target = '/updateAddress/'
  return request.post(target, form)
}


export function addAddress(form) {
  let target = '/addAddress/'
  return request.post(target, form)
}

// 删除购物车
// const deleteAddress = addressID =>
//   axios
//     .delete('/api/v1/addresses', {
//       data: { address_id: addressID }
//     })
//     .then(res => res.data)
export function deleteAddress(addressID) {
  let target = '/deleteAddress?id='
  target += addressID
  return request.delete(target, addressID)
}


// export { deleteAddress }
